<script src="{{ asset("js/jquery.fancybox.pack.js") }}"></script>
<link href="{{ asset("css/fancybox2/jquery.fancybox.css") }}" rel="stylesheet" type="text/css" media="screen" />

<script type="text/javascript">
    $(document).ready(function() {
        $('.mmEditInfo').click(function() {
            var target = $(this).siblings('.mmPictureInfo');
            if (!target.hasClass('open')) {
                target.fadeIn();
                target.addClass('open');
                $(this).addClass('active');
            } else {
                target.removeClass('open');
                $(this).removeClass('active');
                target.fadeOut();
            }

            return false;
        });
    });
</script>

<hr />

{{ form.file(
    {
        'id': 'picture',
        'name': 'pictures[]',
        'labelName': 'Снимка'
    }
) }}

{% if pictures is defined and pictures|length %}
    <div class="form-group">
        {% for SOGI in pictures %}
            <div class="col-sm-offset-2 col-sm-3">
                {#<input type="checkbox" id="giActive" {% if MainSOGI.isActive %}checked="checked"{% endif %} name="giActive" value="1" />
                <label for="giActive">Видима</label>#}

                <a href="{{ img(SOGI, {'src': true}) }}" title='Заглавие: {{ SOGI.title|raw }}<br/>Описание: {{ SOGI.description|raw }}' class="fancybox" >
                    {{ img(SOGI, {'width': 300, 'height': 200, 'crop': true})|raw }}
                </a>
                <br />
                <br/>
                <a href="#" class='mmEditInfo btn alert-info'><i class="glyphicon glyphicon-edit">&nbsp;</i>Редактирай</a>
                <a href="{{ path('admin_delete_sogi', {id: SOGI.id}) }}" data-message="Сигурни ли сте че искате да изтриете тази снимка?" class='confirm btn alert-danger'><i class="glyphicon glyphicon-remove">&nbsp;</i>Изтрий</a>

                <div class="mmPictureInfo" style="display:none;">
                    Заглавие:
                    <input style="width: 304px;" type="text" name="mmItems[{{ SOGI.id }}][title]" value="{{ SOGI.title|raw }}" />
                    Описание:
                    <textarea style="width: 304px; height: 100px;" name="mmItems[{{ SOGI.id }}][description]" >{{ SOGI.description|raw }}</textarea>
                </div><br />
                <br />
            </div>
        {% endfor %}
    </div>

    <hr />
    {{ form.submit({backword: 'admin_pages'}) }}
{% endif %}